// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {
        let handler = {
            get: function(target, key) {
                console.log('getting '+key);
                return target[key]; // 不是target.key
            },
            set: function(target, key, value) {
      
                target[key] = value;
                console.log('setting '+value);
                return true;
            }
        }
        let obj={_rotation: 0,
        get rotation(){
            return this._rotation;
        },
        set rotation(v){
            console.log(v);
            this._rotation=v;
        }
        }
        let proxy = new Proxy(obj, handler)

        cc['tween'](proxy)
        .to(1, { rotation:300})
        .start()
         return;
    }

    // update (dt) {}
}
